#include "triggernode.h"

 static struct trigger_node trignode[__MAXTRIGSRC];

SIG_SLOT_MANAGER glb_signalslot = {
    .trignode = trignode,
};
static SIG_SLOT_MANAGER *pglb_slomanager = &glb_signalslot;

void trigger_connect(void*sender, uint8_t type, void*recver, _func slot)
{
    pglb_slomanager->trignode[type].sender = sender;
    pglb_slomanager->trignode[type].recver = recver;
    pglb_slomanager->trignode[type].slot = slot;
    pglb_slomanager->trignode[type].trigsrc = type;
}

void trigger_emit(uint8_t type, void* param)
{
    void *sender = pglb_slomanager->trignode[type].sender;
    void *recver = pglb_slomanager->trignode[type].recver;
    pglb_slomanager->trignode[type].slot(sender,type,recver,param);
}

void trigger_disconnect(void*sender, uint8_t type, void*recver,void*slot)
{
    pglb_slomanager->trignode[type].sender = 0;
    pglb_slomanager->trignode[type].recver = 0;
    pglb_slomanager->trignode[type].slot = 0;
    pglb_slomanager->trignode[type].trigsrc = 0;
}

